<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Hocphi extends MY_Controller {

	public $data 	= 	array();
 	public $_template = array();
	public function __construct() {
		//parent::Controller();
		parent::__construct(); //for CI 2.x users 
		$this->load->module_model('member', 'qlsv_model', 'hocphi');
		$this->load->module_language('member', 'qlsv');
		$this->load->helper('text');
		$this->user = $this->access->get_user();
		$this->load->helper('url');
		$this->access->restrict();
	}
	
 
	public function index() 
	{
		$this->access->restrict('Member.Hocphi.Index');
		$data['ItemID'] = 'User';
		$data['title'] = 'Bảng thu học phí';
		$data['description'] = 'Bảng thu học phí';
		
		$this->access->restrict();
		$this->load->library('basic_library');
		$this->load->library('pagination');
		
		$config = array();
		$config['base_url'] = base_url().'member/hocphi/index/';
		$config['total_rows'] = $this->hocphi->count_all_hocphi();
		$config['per_page'] = 30;
		$config['uri_segment'] = 4;
		$config['num_links'] = 5;
		$config['first_link'] = 'First';
        $config['last_link'] = 'Last';
        $config['next_link'] = 'Next';
        $config['prev_link'] = 'Prev';
		$this->pagination->initialize($config);
		$page = ($this->uri->segment(4))? $this->uri->segment(4):0;
		$data['sotrang']	=	$this->uri->segment(4);
		$data['allhocphi'] = $this->hocphi->get_all_hocphi($config['per_page'], $page);
		$data['links'] = $this->pagination->create_links();		
		
		$this->_template['page']	= 'users/hocphi/list';
		$this->system_library->load($this->_template['page'], $data);
	}
	
	public function view($id)
	{
		$this->access->restrict('Member.Hocphi.View');
		$data['info'] = $this->hocphi->get_thong_tin_hoc_phi($id);
		//$data['info'] = $this->hocphi->get_hv($id);
		$data['id']	=	$id;
		$this->load->view('templates/default/layout/pages/users/hocphi/view', $data);
	}
	
	public function congno()
	{
		$data['ItemID'] = 'User';
		$data['title'] = 'Danh sách công nợ Học phí';
		$data['description'] = 'Danh sách công nợ';
		$data['congno'] = $this->hocphi->get_congno();
		
		$this->_template['page']	= 'users/hocphi/congno';
		$this->system_library->load($this->_template['page'], $data);
	}
	
	public function ajax_save_hocphi()
	{
		$id = $this->input->post('id');
		//echo $product_id;
		//$user_id = $this->session->userdata('id');
		
		$price = $this->input->post('price');
		$phainop = $this->input->post('phainop');
		//log_message('DEBUG',' heariing '. $price . ' | '. $product_id);
		$json = array();
		if($this->hocphi->ajax_save_hocphi($id, $price,$phainop))
		{
			$json['result'] = 1;
		}
		else
		{
			$json['result'] = 0;
		}
		
		echo json_encode($json);
	}
	
	public function lock()
	{
		$id = $this->input->post('id');
		$json = array();
		if($this->hocphi->lock_hocphi($id) == true)
		{
			$json['result'] = 1;
		}
		else
		{
			$json['result'] = 0;
		}
		echo json_encode($json);
	}
}

/* End of file welcome.php */
/* Location: ./application/controllers/products.php */